package com.virtualparadigm.identity;

import org.apache.commons.lang.builder.EqualsBuilder;
import org.apache.commons.lang.builder.HashCodeBuilder;
import org.apache.commons.lang.builder.ReflectionToStringBuilder;

import com.virtualparadigm.compositor.ToStringStyleBuilder;

public class TupleGUID implements GUID
{
	private static final long serialVersionUID = 1L;
	private Object[] tuples;
	
	public TupleGUID(Object... tuples)
	{
		super();
		this.tuples = tuples;
	}

	private Object[] getTuples()
	{
		return tuples;
	}

	@Override
	public String getUniqueHash()
	{
		return String.valueOf(this.hashCode());
	}

	//  ================================================================
	//  UTILITY METHODS
	//  ================================================================
	public int hashCode()
	{
		HashCodeBuilder builder = new HashCodeBuilder(17,31);
	    builder.append(this.getTuples());
	    return builder.toHashCode();		
	}
	public boolean equals(Object obj)
	{
		if (obj == null)
		{
			return false;
		}
		if (obj == this)
		{
			return true;
		}
		if (obj.getClass() != getClass())
		{
			return false;
		}
		TupleGUID that = (TupleGUID)obj;
		EqualsBuilder builder = new EqualsBuilder();
	    builder.append(this.getTuples(), that.getTuples());
		return builder.isEquals();
	}
	public String toString()
	{
//		return ReflectionToStringBuilder.toString(this, ToStringStyle.MULTI_LINE_STYLE);
		return ReflectionToStringBuilder.toString(this, ToStringStyleBuilder.toStringStyle);
	}

}
